package operation.duoxianliu.demo08;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
import java.util.stream.Collectors;

public class Double01 implements Runnable {
    private Random r = new Random();
    private int per = 100;
    ArrayList<Integer> list = new ArrayList<>();
    @Override
    public void run() {
        int a = 0;
        while (true) {
            synchronized (this) {
                String name=Thread.currentThread().getName();
                if (per <= 0) {
                    System.out.println("从"+name+"入场的员工总数为:"+a);
                    break;
                }
                while (list.size() < 6) {
                    int i = r.nextInt(33) + 1;
                    if (!list.contains(i)) {
                        list.add(i);
                    }
                }
                Collections.sort(list);
                int i = r.nextInt(16)+1;
                list.add(i);
                System.out.println("编号为"+(101-per)+"的员工 从"+name+"入场! 拿到的双色球号为:"+list);
                per--;
                a++;
                list.clear();
            }
        }

    }
}
